﻿using Dm.util;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataCollection.Core.Models
{
    /// <summary>
    /// 试压工程
    ///</summary>
    [SugarTable("c_project")]
    public class ProjectModel
    {
        #region 属性
        /// <summary>
        /// 备  注:工程编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public long Number { get; set; }

        /// <summary>
        /// 备  注:工程名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:工程桩号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "stake_mark")]
        public string StakeMark { get; set; } = null!;

        /// <summary>
        /// 备  注:管材规格
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_specification")]
        public string PipeSpecification { get; set; } = null!;

        /// <summary>
        /// 备  注:管道长度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_length")]
        public string PipeLength { get; set; } = null!;

        /// <summary>
        /// 备  注:试压介质
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "medium")]
        public string Medium { get; set; } = null!;

        /// <summary>
        /// 备  注:设计压力
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "design_pressure")]
        public double DesignPressure { get; set; }

        /// <summary>
        /// 备  注:管道性质
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "pipe_nature")]
        public string PipeNature { get; set; } = null!;

        /// <summary>
        /// 备  注:试压类型
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "test_type")]
        public string TestType { get; set; } = null!;

        /// <summary>
        /// 备  注:施工单位
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "company")]
        public string Company { get; set; } = null!;

        /// <summary>
        /// 备  注:压力表精度
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "manometer_precision")]
        public string ManometerPrecision { get; set; } = null!;

        /// <summary>
        /// 备  注:压力表量程
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "manometer_range")]
        public string ManometerRange { get; set; } = null!;

        /// <summary>
        /// 备  注:试压模板ID
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "template_id")]
        public long TemplateID { get; set; }

        #endregion

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            List<ProjectModel> list = new List<ProjectModel>();
            list.Add(this);
            int res = SqlSugarHelper.Insertable<ProjectModel>(list);
            return res;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            List<ProjectModel> list = new List<ProjectModel>();
            list.Add(this);
            int res = SqlSugarHelper.Deleteable<ProjectModel>(list);
            return res;
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        public int Update()
        {
            List<ProjectModel> list = new List<ProjectModel>();
            list.Add(this);
            int res = SqlSugarHelper.Updateable<ProjectModel>(list);
            return res;
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<ProjectModel> List(Dictionary<string, object> where)
        {

            return SqlSugarHelper.Inquireable<ProjectModel>(where);
        }

        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<ProjectModel> ListPage(Dictionary<string, object> where, int page, int pageSize, ref int totalCount)
        {
            return SqlSugarHelper.InquireableToPageList<ProjectModel>(where, page, pageSize, ref totalCount);
        }
    }
}
